from datetime import datetime

from fastapi_users_db_sqlalchemy import SQLAlchemyBaseUserTable
from sqlalchemy import Table, Column, Integer, TIMESTAMP, MetaData, ForeignKey, Numeric
from sqlalchemy.orm import DeclarativeBase

from auth.models import user
from database import Base

metadata = MetaData()

salaries = Table(
    "salaries",
    metadata,
    Column("id", Integer, primary_key=True),
    Column("salary", Numeric(10, 2)),
    Column("raising_data", TIMESTAMP),
    Column("user_id", Integer, ForeignKey(user.c.id))
)

class Base(DeclarativeBase):
    pass

class Salary(Base):
    __table_args__ = {'extend_existing': True}
    __tablename__ = "salaries"
    id = Column(Integer, primary_key=True)
    salary = Column(Numeric(10, 2), nullable=False)
    raising_data = Column(TIMESTAMP, default=datetime.utcnow)
    user_id = Column(Integer, ForeignKey(user.c.id))
